/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.swt.mto.thithu.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.swt.mto.thithu.model.Quiz;
import com.swt.mto.thithu.model.QuizModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the Quiz service. Represents a row in the &quot;mto_thithu_Quiz&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.swt.mto.thithu.model.QuizModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link QuizImpl}.
 * </p>
 *
 * @author tuan.nguyen
 * @see QuizImpl
 * @see com.swt.mto.thithu.model.Quiz
 * @see com.swt.mto.thithu.model.QuizModel
 * @generated
 */
public class QuizModelImpl extends BaseModelImpl<Quiz> implements QuizModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a quiz model instance should use the {@link com.swt.mto.thithu.model.Quiz} interface instead.
	 */
	public static final String TABLE_NAME = "mto_thithu_Quiz";
	public static final Object[][] TABLE_COLUMNS = {
			{ "quizId", Types.BIGINT },
			{ "createUserId", Types.BIGINT },
			{ "modifyUserId", Types.BIGINT },
			{ "quizCategoryId", Types.BIGINT },
			{ "title", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "createDate", Types.TIMESTAMP },
			{ "modifydate", Types.TIMESTAMP },
			{ "time_", Types.INTEGER }
		};
	public static final String TABLE_SQL_CREATE = "create table mto_thithu_Quiz (quizId LONG not null primary key,createUserId LONG,modifyUserId LONG,quizCategoryId LONG,title VARCHAR(75) null,description VARCHAR(75) null,createDate DATE null,modifydate DATE null,time_ INTEGER)";
	public static final String TABLE_SQL_DROP = "drop table mto_thithu_Quiz";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.swt.mto.thithu.model.Quiz"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.swt.mto.thithu.model.Quiz"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.swt.mto.thithu.model.Quiz"));

	public QuizModelImpl() {
	}

	public long getPrimaryKey() {
		return _quizId;
	}

	public void setPrimaryKey(long primaryKey) {
		setQuizId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_quizId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return Quiz.class;
	}

	public String getModelClassName() {
		return Quiz.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("quizId", getQuizId());
		attributes.put("createUserId", getCreateUserId());
		attributes.put("modifyUserId", getModifyUserId());
		attributes.put("quizCategoryId", getQuizCategoryId());
		attributes.put("title", getTitle());
		attributes.put("description", getDescription());
		attributes.put("createDate", getCreateDate());
		attributes.put("modifydate", getModifydate());
		attributes.put("time", getTime());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long quizId = (Long)attributes.get("quizId");

		if (quizId != null) {
			setQuizId(quizId);
		}

		Long createUserId = (Long)attributes.get("createUserId");

		if (createUserId != null) {
			setCreateUserId(createUserId);
		}

		Long modifyUserId = (Long)attributes.get("modifyUserId");

		if (modifyUserId != null) {
			setModifyUserId(modifyUserId);
		}

		Long quizCategoryId = (Long)attributes.get("quizCategoryId");

		if (quizCategoryId != null) {
			setQuizCategoryId(quizCategoryId);
		}

		String title = (String)attributes.get("title");

		if (title != null) {
			setTitle(title);
		}

		String description = (String)attributes.get("description");

		if (description != null) {
			setDescription(description);
		}

		Date createDate = (Date)attributes.get("createDate");

		if (createDate != null) {
			setCreateDate(createDate);
		}

		Date modifydate = (Date)attributes.get("modifydate");

		if (modifydate != null) {
			setModifydate(modifydate);
		}

		Integer time = (Integer)attributes.get("time");

		if (time != null) {
			setTime(time);
		}
	}

	public long getQuizId() {
		return _quizId;
	}

	public void setQuizId(long quizId) {
		_quizId = quizId;
	}

	public long getCreateUserId() {
		return _createUserId;
	}

	public void setCreateUserId(long createUserId) {
		_createUserId = createUserId;
	}

	public String getCreateUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getCreateUserId(), "uuid",
			_createUserUuid);
	}

	public void setCreateUserUuid(String createUserUuid) {
		_createUserUuid = createUserUuid;
	}

	public long getModifyUserId() {
		return _modifyUserId;
	}

	public void setModifyUserId(long modifyUserId) {
		_modifyUserId = modifyUserId;
	}

	public String getModifyUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getModifyUserId(), "uuid",
			_modifyUserUuid);
	}

	public void setModifyUserUuid(String modifyUserUuid) {
		_modifyUserUuid = modifyUserUuid;
	}

	public long getQuizCategoryId() {
		return _quizCategoryId;
	}

	public void setQuizCategoryId(long quizCategoryId) {
		_quizCategoryId = quizCategoryId;
	}

	public String getTitle() {
		if (_title == null) {
			return StringPool.BLANK;
		}
		else {
			return _title;
		}
	}

	public void setTitle(String title) {
		_title = title;
	}

	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public Date getModifydate() {
		return _modifydate;
	}

	public void setModifydate(Date modifydate) {
		_modifydate = modifydate;
	}

	public int getTime() {
		return _time;
	}

	public void setTime(int time) {
		_time = time;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			Quiz.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public Quiz toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (Quiz)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		QuizImpl quizImpl = new QuizImpl();

		quizImpl.setQuizId(getQuizId());
		quizImpl.setCreateUserId(getCreateUserId());
		quizImpl.setModifyUserId(getModifyUserId());
		quizImpl.setQuizCategoryId(getQuizCategoryId());
		quizImpl.setTitle(getTitle());
		quizImpl.setDescription(getDescription());
		quizImpl.setCreateDate(getCreateDate());
		quizImpl.setModifydate(getModifydate());
		quizImpl.setTime(getTime());

		quizImpl.resetOriginalValues();

		return quizImpl;
	}

	public int compareTo(Quiz quiz) {
		long primaryKey = quiz.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		Quiz quiz = null;

		try {
			quiz = (Quiz)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = quiz.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<Quiz> toCacheModel() {
		QuizCacheModel quizCacheModel = new QuizCacheModel();

		quizCacheModel.quizId = getQuizId();

		quizCacheModel.createUserId = getCreateUserId();

		quizCacheModel.modifyUserId = getModifyUserId();

		quizCacheModel.quizCategoryId = getQuizCategoryId();

		quizCacheModel.title = getTitle();

		String title = quizCacheModel.title;

		if ((title != null) && (title.length() == 0)) {
			quizCacheModel.title = null;
		}

		quizCacheModel.description = getDescription();

		String description = quizCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			quizCacheModel.description = null;
		}

		Date createDate = getCreateDate();

		if (createDate != null) {
			quizCacheModel.createDate = createDate.getTime();
		}
		else {
			quizCacheModel.createDate = Long.MIN_VALUE;
		}

		Date modifydate = getModifydate();

		if (modifydate != null) {
			quizCacheModel.modifydate = modifydate.getTime();
		}
		else {
			quizCacheModel.modifydate = Long.MIN_VALUE;
		}

		quizCacheModel.time = getTime();

		return quizCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(19);

		sb.append("{quizId=");
		sb.append(getQuizId());
		sb.append(", createUserId=");
		sb.append(getCreateUserId());
		sb.append(", modifyUserId=");
		sb.append(getModifyUserId());
		sb.append(", quizCategoryId=");
		sb.append(getQuizCategoryId());
		sb.append(", title=");
		sb.append(getTitle());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifydate=");
		sb.append(getModifydate());
		sb.append(", time=");
		sb.append(getTime());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(31);

		sb.append("<model><model-name>");
		sb.append("com.swt.mto.thithu.model.Quiz");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>quizId</column-name><column-value><![CDATA[");
		sb.append(getQuizId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createUserId</column-name><column-value><![CDATA[");
		sb.append(getCreateUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifyUserId</column-name><column-value><![CDATA[");
		sb.append(getModifyUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>quizCategoryId</column-name><column-value><![CDATA[");
		sb.append(getQuizCategoryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>title</column-name><column-value><![CDATA[");
		sb.append(getTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifydate</column-name><column-value><![CDATA[");
		sb.append(getModifydate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>time</column-name><column-value><![CDATA[");
		sb.append(getTime());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = Quiz.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			Quiz.class
		};
	private long _quizId;
	private long _createUserId;
	private String _createUserUuid;
	private long _modifyUserId;
	private String _modifyUserUuid;
	private long _quizCategoryId;
	private String _title;
	private String _description;
	private Date _createDate;
	private Date _modifydate;
	private int _time;
	private Quiz _escapedModelProxy;
}